<script setup lang="ts">
import * as Enums from '@firewall/engine/Enums';

const { t } = useI18n({ inheritLocale: true, useScope: 'local' });

interface Props {
  origin?: string,
}
const props = withDefaults(defineProps<Props>(), {
  origin: () => '',
});
type Emit = {
  (e: 'update:origin', value: string): void,
}
const emit = defineEmits<Emit>();

onMounted(() => {
  emit('update:origin', Enums.LogOrigin.All);
});

const onSelectorChange = (value: string) => {
  emit('update:origin', value);
};
</script>

<template>
  <ElSelect
    :model-value="props.origin"
    class="log-origin-selector"
    filterable
    @change="onSelectorChange"
  >
    <ElOption
      v-for="origin in Enums.LogOrigin"
      :key="origin"
      :value="origin"
      :label="t(`logOrigin.${origin}`)"
    />
  </ElSelect>
</template>

<i18n lang="yaml" locale="zh-CN">
  logOrigin:
    all: '全部判断来源'
    1: '虚拟补丁'
    2: '基础防御'
</i18n>

<style lang="scss" scoped>
.log-origin-selector {
  width: 140px;
}
</style>
